package com.demo3;


import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class SmartHandler implements InvocationHandler {
    private SmartAnimal smartAnimal;

    public SmartHandler(SmartAnimal smartAnimal) {
        this.smartAnimal = smartAnimal;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("方法运行前");
        Object result = method.invoke(smartAnimal,args);
        System.out.println("方法运行后,结果是:"+result);
        return result;
    }
}
